<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>3d翻书动画</title>
    <style>
      .pages{
        width: 500px;
        height: 500px;
        margin: 100px auto;
      }
      .page-1-back,
      .page-2-back {
        transform: scale(-1, 1);
      }
      .page-1,
      .page-2 {
        z-index: 1;
      }
      @keyframes flip-to-left {
        from {
          transform: rotateY(0);
        }
        to {
          transform: rotateY(-180deg);
        }
      }
      .paper[data-right] {
        transform-origin: left center;
        animation: flip-to-left 2s ease-in-out;
      }
      .paper {
        display: none;
        position: absolute;
        /* 默认放在右边 */
        right: 0;
      }
      .paper[data-left],
      .paper[data-right] {
        display: block;
        z-index: 1;
      }
      .paper[data-left] {
        right: auto;
        left: 0;
      }
      /* 把相邻的paper显示出来 */
      .paper[data-right] + .paper {
        display: block;
      }
      .paper {
        transform-style: preserve-3d;
      }
      .page-1,
      .page-2 {
        transform: translateZ(1px);
      }
      @keyframes flip-to-left {
        from {
          transform: perspective(1000px) rotateY(0);
        }
        to {
          transform: perspective(1000px) rotateY(-180deg);
        }
      }
      .paper[data-right] {
        transform-origin: left center;
        animation: flip-to-left 2s ease-in-out forwards;
      }
    </style>
</head>
<body>
  <ul class="pages">
    <!--一个li.paper包含了正反两页-->
    <li class="paper" data-left>
        <!--一个.page就是一页内容-->
        <div class="page page-1-back">
            <img src="./images/1.jpg" alt>
        </div>
        <div class="page page-1">
            <img src="./images/2.jpg" alt>
        </div>
    </li>
    <li class="paper" data-right>
        <div class="page page-2">
            <img src="./images/3.jpg" alt>
        </div>
        <div class="page page-2-back">
            <img src="./images/4.jpg" alt>
        </div>
    </li>
    <!--其它页内容省略-->
  </ul>
            
</body>
</html>